package cn.duwey.scs.api.user;

import cn.duwey.scs.api.user.dto.UserDTO;
import cn.duwey.scs.common.dto.PageResult;
import cn.duwey.scs.common.dto.ServiceResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@FeignClient("scs-user-service")
@RequestMapping("/api/user")
public interface UserApi {

    @PutMapping(value = "/createUser", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ServiceResult<UserDTO> createUser(@RequestBody UserDTO userDTO);

    @PostMapping(value = "/updateById", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ServiceResult<UserDTO> updateById(@RequestBody UserDTO userDTO);

    @GetMapping(value = "/{id}")
    ServiceResult<UserDTO> findById(@PathVariable("id") Long id);

    @PostMapping(value = "/findByUsername", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    ServiceResult<UserDTO> findByUsername(@RequestParam("username") String username);

    @PostMapping(value = "/findPage", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    ServiceResult<PageResult<UserDTO>> findPage(@RequestParam("currentPage") Integer currentPage,
            @RequestParam("pageSize") Integer pageSize);

}
